package frame.edit 
{
	import config.COLORCONFIG;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	import nsdecl.ns_dialog_service;
	import proxy.DataAccess;
	import ui.ui_text;
	import ui.uiWin;
	
	/**
	 * 编辑页
	 * @author anod
	 */
	public class EditPage extends uiWin
	{
		private static var cStatusBar:ui_text;
		private static var cStatusTween:Timer;
		
		public function EditPage() 
		{
			super();
			( cStatusBar == null ) && (cStatusBar = new ui_text());
		}
		
		//主功能服务
		//------------------------------------
		public function saveToDisk():void
		{
			DataAccess.instance.saveToDisk();
		}
		
		override public function onClose(...arg):void 
		{
			saveToDisk();
			super.onClose();
		}
		
		ns_dialog_service function notify( msg:String, screenx:int=567, screeny:int=576 ):void
		{
			with ( cStatusBar )
			{
				text = msg, x = screenx, y = screeny;
				mouseChildren = mouseEnabled = false;
				color = 0;
			}
			cStatusBar.show_display();
			addChild( cStatusBar );
			
			cStatusTween && ( cStatusTween.stop() || cStatusTween.removeEventListener(TimerEvent.TIMER, statusTween) );
			cStatusTween = new Timer(50, 100);
			cStatusTween.addEventListener(TimerEvent.TIMER, statusTween);
			cStatusTween.start();
		}
		private function statusTween( e:TimerEvent ):void
		{
			if ( cStatusTween.currentCount == cStatusTween.repeatCount ) 
				(cStatusBar.alpha = 1.0) && (cStatusBar.parent) && cStatusBar.parent.removeChild( cStatusBar );
			
			cStatusBar.alpha = (cStatusTween.repeatCount - cStatusTween.currentCount) / cStatusTween.repeatCount;
		}
	}
}